package com.punai.standard.controller;

import com.punai.common.annotation.Log;
import com.punai.common.core.controller.BaseController;
import com.punai.common.core.domain.AjaxResult;
import com.punai.common.core.page.TableDataInfo;
import com.punai.common.enums.BusinessType;
import com.punai.standard.domain.StaGxLinkGkCategories;
import com.punai.standard.service.IStaGxLinkGkCategoriesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 标准费用项下材料类别关联归口Controller
 * 
 * @author zhx
 * @date 2023-06-26
 */
@RestController
@RequestMapping("/sta/staGxLinkGkCategories")
public class StaGxLinkGkCategoriesController extends BaseController
{
    @Autowired
    private IStaGxLinkGkCategoriesService staGxLinkGkCategoriesService;

    /**
     * 查询标准费用项下材料类别关联归口列表
     */
    @PreAuthorize("@ss.hasPermi('sta:staGxLinkGkCategories:list')")
    @GetMapping("/list")
    public TableDataInfo list(StaGxLinkGkCategories staGxLinkGkCategories)
    {
        startPage();
        List<StaGxLinkGkCategories> list = staGxLinkGkCategoriesService.selectStaGxLinkGkCategoriesList(staGxLinkGkCategories);
        return getDataTable(list);
    }

    /**
     * 获取标准费用项下材料类别关联归口详细信息
     */
    @PreAuthorize("@ss.hasPermi('sta:staGxLinkGkCategories:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(staGxLinkGkCategoriesService.selectStaGxLinkGkCategoriesById(id));
    }

    /**
     * 新增标准费用项下材料类别关联归口
     */
    @PreAuthorize("@ss.hasPermi('sta:staGxLinkGkCategories:add')")
    @Log(title = "标准费用项下材料类别关联归口", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StaGxLinkGkCategories staGxLinkGkCategories)
    {
        return toAjax(staGxLinkGkCategoriesService.insertStaGxLinkGkCategories(staGxLinkGkCategories));
    }

    /**
     * 修改标准费用项下材料类别关联归口
     */
    @PreAuthorize("@ss.hasPermi('sta:staGxLinkGkCategories:edit')")
    @Log(title = "标准费用项下材料类别关联归口", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StaGxLinkGkCategories staGxLinkGkCategories)
    {
        return toAjax(staGxLinkGkCategoriesService.updateStaGxLinkGkCategories(staGxLinkGkCategories));
    }
}
